package com.zhaungjie.base.utils;

import java.util.Random;

/**
 * 随机数字字符生成器
 * @author zhuangjie
 * @date 2023/09/26
 */
public class CodeRandomGenerator {
    public static String gen(Integer length) {
        Random random = new Random();
        StringBuilder randomNumber = new StringBuilder();

        for (int i = 0; i < length; i++) {
            int randomDigit = random.nextInt(10);
            randomNumber.append(Integer.toString(randomDigit));
        }

        return randomNumber.toString();
    }
    public static String gen() {
        return gen(4);
    }
}
